package com.sztz.mapstruct.F指定对象全转换;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
 * CarMapper
 *
 * @author yyf
 * @email yeyafei@hotmail.com
 */
@Mapper
public interface CarMapper {

    CarMapper INSTANCE = Mappers.getMapper(CarMapper.class);

    /**
     * . 可指定全部对象映射
     *
     * @param car
     * @return CarDto
     */
    @Mapping(source = ".", target = "owner")
    CarDTO toDto(Car car);

    /**
     * . 也适用于 target
     *
     * @param dto
     * @return Car
     */
    @Mapping(source = "owner", target = ".")
    Car toDto(CarDTO dto);
}
